using UnityEngine;
using UnityEngine.UI;

namespace MaterialUI
{
	[ExecuteInEditMode]
	[AddComponentMenu("MaterialUI/Material Radio", 100)]
	public class MaterialRadio : ToggleBase
	{
		[SerializeField]
		private Graphic m_DotImage;

		[SerializeField]
		private Graphic m_RingImage;

		private float m_CurrentDotSize;

		public override void TurnOn()
		{
			Vector2 sizeDelta = m_DotImage.rectTransform.sizeDelta;
			m_CurrentDotSize = sizeDelta.x;
			m_CurrentColor = m_DotImage.color;
			base.TurnOn();
		}

		public override void TurnOnInstant()
		{
			base.TurnOnInstant();
			if (base.toggle.interactable)
			{
				m_DotImage.color = m_OnColor;
				m_RingImage.color = m_OnColor;
			}
			m_DotImage.rectTransform.sizeDelta = new Vector2(24f, 24f);
		}

		public override void TurnOff()
		{
			Vector2 sizeDelta = m_DotImage.rectTransform.sizeDelta;
			m_CurrentDotSize = sizeDelta.x;
			m_CurrentColor = m_DotImage.color;
			base.TurnOff();
		}

		public override void TurnOffInstant()
		{
			base.TurnOffInstant();
			if (base.toggle.interactable)
			{
				m_DotImage.color = m_OffColor;
				m_RingImage.color = m_OffColor;
			}
			m_DotImage.rectTransform.sizeDelta = Vector2.zero;
		}

		public override void Enable()
		{
			if (base.toggle.isOn)
			{
				m_DotImage.color = m_OnColor;
				m_RingImage.color = m_OnColor;
			}
			else
			{
				m_DotImage.color = m_OffColor;
				m_RingImage.color = m_OffColor;
			}
			base.Enable();
		}

		public override void Disable()
		{
			m_DotImage.color = m_DisabledColor;
			m_RingImage.color = m_DisabledColor;
			base.Disable();
		}

		public override void AnimOn()
		{
			base.AnimOn();
			m_DotImage.color = Tween.QuintOut(m_CurrentColor, m_OnColor, m_AnimDeltaTime, m_AnimationDuration);
			m_RingImage.color = m_DotImage.color;
			float num = Tween.QuintOut(m_CurrentDotSize, 24f, m_AnimDeltaTime, m_AnimationDuration);
			m_DotImage.rectTransform.sizeDelta = new Vector2(num, num);
		}

		public override void AnimOnComplete()
		{
			base.AnimOnComplete();
			m_DotImage.color = m_OnColor;
			m_RingImage.color = m_OnColor;
			m_DotImage.rectTransform.sizeDelta = new Vector2(24f, 24f);
		}

		public override void AnimOff()
		{
			base.AnimOff();
			m_DotImage.color = Tween.QuintOut(m_CurrentColor, m_OffColor, m_AnimDeltaTime, m_AnimationDuration);
			m_RingImage.color = m_DotImage.color;
			float num = Tween.QuintOut(m_CurrentDotSize, 0f, m_AnimDeltaTime, m_AnimationDuration);
			m_DotImage.rectTransform.sizeDelta = new Vector2(num, num);
		}

		public override void AnimOffComplete()
		{
			base.AnimOffComplete();
			m_DotImage.color = m_OffColor;
			m_RingImage.color = m_OffColor;
			m_DotImage.rectTransform.sizeDelta = Vector2.zero;
		}
	}
}
